#include "UArcBall.h"

TArcBall::TArcBall(GLfloat windowWidth, GLfloat windowHeight, GLfloat xPosition, GLfloat yPosition, GLfloat ballwidth) {
	width = windowWidth;
	height = windowHeight;
	diameter = ballwidth;
	x = xPosition;
	y = yPosition;
	ballQuadric=gluNewQuadric();			// Create A Pointer To The Quadric Object ( NEW )
	gluQuadricNormals(ballQuadric, GLU_SMOOTH);	// Create Smooth Normals ( NEW )
}

void TArcBall::update(GLfloat x, GLfloat y) {
}

void TArcBall::getRotation(GLfloat& x, GLfloat& y, GLfloat& z) {
}

void TArcBall::draw() {
	GLint polymode[2];
	GLfloat color[4];
	GLboolean light;
	GLboolean culling;
	GLint matrixMode;
	glGetIntegerv(GL_POLYGON_MODE, polymode);
	glGetFloatv(GL_CURRENT_COLOR, color);
	glGetBooleanv(GL_LIGHTING, &light);
	glGetBooleanv(GL_CULL_FACE, &culling);
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	glColor4f(1,1,0,1);
	glDisable(GL_LIGHTING);
	glDisable(GL_CULL_FACE);
	glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
/*	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0, width, height, 0, -1,1);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(x, y, 0);*/
	gluSphere(ballQuadric, diameter, 32, 32);
/*	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(matrixMode);*/
	glColor4f(color[0],color[1],color[2], color[3]);
	glPolygonMode(GL_FRONT, polymode[0]);
	glPolygonMode(GL_BACK, polymode[1]);
	if(light) glEnable(GL_LIGHTING);
	if(culling) glEnable(GL_CULL_FACE);
}
